#include "xp_mem_pool.h"
#include "cmsis_os.h"

static ncx_slab_pool_t *sp = NULL;

bool sys_mem_pool_init(size_t 	pool_size)
{
	ncx_slab_stat_t stat;
	u_char 	*space;
	space = (u_char *)pvPortMalloc(pool_size);

	if(space){
		sp = (ncx_slab_pool_t*) space;

		sp->addr = space;
		sp->min_shift = 3;
		sp->end = space + pool_size;

		ncx_slab_init(sp);
		
		return true;
	} else
		return false;
}

void * xp_malloc(size_t size)
{
	return ncx_slab_alloc(sp, size); 
}

void xp_free(void *p)
{
	ncx_slab_free(sp, p); 
}